import { defineStore } from 'pinia'
import { ref } from 'vue'
import { persistedState } from './defaultConfig.js'

export const useCounterStore = defineStore(
  'counter',
  () => {
    const count = ref(0)
    function increment() {
      count.value++
    }

    function decrement() {
      count.value--
    }
    const obj = ref({
      name: 'zs',
      age: 18,
    })
    return { count, increment, decrement, obj }
  },
  {
    // persist: true // 会持久化所有的响应式数据（默认持久化至浏览器的localStorage）
    persist: {
      paths: ['count', 'obj.name'],
    },
  }
)
